package org.mall.modules.pay.client;

import org.mall.common.constant.PayErrorCodeEnum;
import org.mall.common.util.ServiceExceptionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PaySDKFactory {

    @Autowired
    WxPaySDK wxPaySDK;
    @Autowired
    AliPaySDK aliPaySDK;


    public  AbstractPaySDK getSDK(Integer payChannel) {
        AbstractPaySDK sdk=null;
        switch (payChannel){
            case 100 :
                sdk=wxPaySDK;
                break;
            case 200:
                sdk=aliPaySDK;
                break;
                default: break;
        }
        if (sdk==null){
            throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
        }
        return sdk;
    }

}